﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using ScrappyDB.BaseClasses;


namespace ScrappyDB.IntegrationTests
{
    [TestFixture]
    public class BasicCodeFirstTest
    {


        [Test]
        public void BasicEfCodeFirstTest()
        {
            var context = new Foo1Context();

            var newFoo = new Foo1
            {
                ID = 99,
                Bar = "blah9"
            };


            context.Foos.Add(newFoo);
            context.Foos.SaveChanges();

            System.Threading.Thread.Sleep(1000);

            //var db = new Db();
            var test = context.Foos.Find(99);

            Assert.AreEqual(99, test.ID);

            context.Foos.Remove(test);
            context.SaveChanges();

            var c = context.Foos.ToList();
            Assert.AreEqual(0,c.Count);
        }

      
    }

    public class Foo1 
    {
        [Key]
        public int ID { get; set; }
        public string Bar { get; set; }
    }

    public class Foo1Context : ScrappyDB.Linq.SdbContext
    {
        public ScrappyDB.Linq.SdbSet<Foo1> Foos { get; set; }
    }
}
